<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../../include/laypublic.jsp" %>
<%@ include file="../../include/vueComponent.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>标书策划详情</title>
</head>
<link rel="stylesheet" href="${ctx}/resources/vue-element-lib/detail.css">
<body>
<div id="app">
    <div class="layui-tab layui-tab-brief" lay-filter="xqxx-tab-all">
        <ul class="layui-tab-title">
            <li id="tbglId" class="layui-this" lay-id="0">标书策划详情
            </li>
            <li id="zgysId" lay-id="1">历史审批信息</li>
        </ul>
        <div class="layui-tab-content" style="height: 100px;">
            <div class="layui-tab-item layui-show">
                <div class="container">
                    <el-form ref="formRef" label-width="180px" label-suffix="："
                             label-position="left">
                        <%--项目基础信息--%>
                        <div class="base-info">
                            <div class="title">
                                <h3>项目基础信息</h3>
                            </div>
                            <!--表单-->
                            <el-row>
                                <x-col>
                                    <el-form-item label="项目名称">
                                        <span>{{info?info.proName:''}}</span>
                                    </el-form-item>
                                </x-col>
                                <x-col position="right">
                                    <el-form-item label="项目业态">
                                        <span>{{info.proFormat}}</span>
                                    </el-form-item>
                                </x-col>

                            </el-row>
                            <el-row>
                                <x-col>
                                    <el-form-item label="项目编码">
                                        <span>{{info.proCode}}</span>
                                    </el-form-item>
                                </x-col>
                                <x-col position="right">
                                    <el-form-item label="所属公司">
                                        <span>{{info.compName}}</span>
                                    </el-form-item>
                                </x-col>
                            </el-row>
                            <el-row>
                                <x-col>
                                    <el-form-item label="营销经理">
                                        <span>{{info.staffName}}</span>
                                    </el-form-item>
                                </x-col>
                            </el-row>
                        </div>
                        <%--项目合作方--%>
                        <div class="title">
                            <h3>投标信息</h3>
                        </div>
                        <el-row>
                            <x-col>
                                <el-form-item label="报名截止日期">
                                    <el-date-picker style="width: 100%" v-model="bidInfo.signupEndDate" type="date"
                                                    value-format="yyyy-MM-dd" disabled
                                                    placeholder="报名截止日期"></el-date-picker>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="资格预审截止日期">
                                    <el-date-picker style="width: 100%" v-model="bidInfo.inquiryEndDate" type="date"
                                                    value-format="yyyy-MM-dd" disabled
                                                    placeholder="资格预审截止日期"></el-date-picker>
                                </el-form-item>
                            </x-col>

                        </el-row>
                        <el-row>
                            <x-col>

                                <el-form-item label="标保证金截止日">
                                    <el-date-picker style="width: 100%" v-model="bidInfo.bondEndDate" type="date"
                                                    value-format="yyyy-MM-dd" disabled
                                                    placeholder="标保证金截止日"></el-date-picker>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="联合体成员">
                                    <span>{{bidInfo.unit}}</span>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <el-row>
                            <x-col>
                                <el-form-item label="报名牵头单位">
                                    <span>{{bidInfo.signupLead}}</span>
                                </el-form-item>
                            </x-col>
                            <x-col position="right">
                                <el-form-item label="投标负责人">
                                    <el-select v-model="bidInfo.bidHead" clearable filterable
                                               placeholder="请选择投标负责人" style="width: 100%" remote disabled
                                               :remote-method="remoteMethod">
                                        <el-option v-for="item in personnel" :key="item.id"
                                                   :label="item.staffName" :value="item.id"></el-option>
                                    </el-select>
                                </el-form-item>
                            </x-col>
                        </el-row>
                        <div class="title">
                            <h3>投标成员信息</h3>
                        </div>
                        <div class="unit">
                            <div class="unit_center">
                                <el-table :data="memberArr" style="width: 100%" border>
                                    <el-table-column prop="bidName" label="标书名称" align="center">
                                        <template slot-scope="scope">
                                            {{scope.row.bidName}}
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="effect" label="姓名" align="center">
                                        <template slot-scope="scope">
                                            <el-select v-model="scope.row.commercePeopleSguid" clearable filterable
                                                       placeholder="请选择" remote :remote-method="remoteMethod" disabled>
                                                <el-option v-for="item in personnel" :key="item.id"
                                                           :label="item.staffName" :value="item.id"></el-option>
                                            </el-select>
                                        </template>
                                    </el-table-column>
                                    <el-table-column prop="type" label="配合人" align="center">
                                        <template slot-scope="scope">
                                            <el-select v-model="scope.row.commerceCooperateSguids" clearable filterable
                                                       multiple remote :remote-method="remoteMethod" disabled
                                                       placeholder="请选择">
                                                <el-option v-for="item in personnel" :key="item.id"
                                                           :label="item.staffName" :value="item.id"></el-option>
                                            </el-select>
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </div>
                        </div>
                        <div class="title">
                            <h3>项目附件信息</h3>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width:350px;">支持pdf、excel、word、图片资料，可上传多个</label>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">附件</label>
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <div class="layui-upload-list" id="15-upload-more-list">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </el-form>
                </div>
            </div>
            <div class="layui-tab-item">
                <%@ include file="lay-processHistory-detail.jsp" %>
            </div>
        </div>
    </div>
</div>
<script src="${ctx}/resources/vue-element-lib/jquery.js"></script>
<script>
    let fileArr = [];
    var staticPath = '${fileHttpPre}';
    layui.config({
        base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set', 'upload', 'table', 'transfer', 'laydate', 'element', 'layer'], function () {
        var $ = layui.$
            , upload = layui.upload
            , table = layui.table
            , element = layui.element
            , layer = layui.layer;
    });

    //删除文件
    function del(index) {
        layui.$("#fileAtt_" + index).remove();
        layui.$("#upload_img_" + index).remove();
        fileArr.map((el, idx) => {
            if (el.split('|')[2] == index) {
                fileArr.splice(idx, 1)
            }
        })
    }

    //根据url查看文件
    function showImg(url) {
        var openWin = window.open(url, '', 'left=410,height=768, width=1024, top=200,  toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
    }

    /*核心*/
    var vm = new Vue({
        el: '#app',
        data() {
            return {
                layId: '0',
                procNodeList: [],
                tempNodeList: [],
                auditMsg: '',//审批意见

                proCode: '',
                info: {},
                memberArr: [],//投标成员信息
                bidInfo: {},
                // proCode: 'JT--20210128-997'
                processId: '',
                id: '',
                allPersonnel: [],//所有人员
                personnel: [],

            }
        },
        created() {
            this.proCode = "${proCode}"
            this.processId = "${processId}";
            this.id = "${id}";
            // this.queryProcessList();
            this.queryPersonnel();
        },
        mounted() {

        },
        methods: {
            remoteMethod(query) {
                let that = this;
                let arr = [];
                console.log(that.allPersonnel.length)
                if (query !== "") {
                    that.allPersonnel.map(el => {
                        if (el.staffName.indexOf(query) != -1) {
                            arr.push(el)
                        }
                    })
                    that.personnel = arr.splice(0, 50);
                } else {
                    that.personnel = that.allPersonnel.splice(0, 50);
                }
            },
            //获取所有人
            queryPersonnel() {
                let that = this;
                const loading = this.$loading({
                    lock: true,
                    text: '拼命加载中',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    type: 'post',
                    url: basePath + '/proSell/queryPersonnel',  //请求数据接口
                    data: {},
                    success: function (result) {
                        if (result && result.length > 0) {
                            that.allPersonnel = result;
                            that.personnel = result.splice(0, 50);
                            loading.close();
                            that.queryProcessList();
                        }
                    }
                });
            },
            showFile(fileList) {
                if (fileList && fileList.length > 0) {
                    fileArr = fileList;
                    for (let i in fileList) {
                        let contractInfo = fileList[i];
                        let arr = contractInfo.split("|");
                        let imgSrc = "";
                        let suffix = arr[1].substring(arr[1].lastIndexOf(".") + 1, arr[1].length);
                        if (suffix == 'jpg' || suffix == 'png') {
                            imgSrc = "${fileHttpPre}/" + arr[3];
                        } else {
                            imgSrc = "${ctx}/resources/images/" + suffix + ".jpg";
                        }
                        $('#' + arr[0] + '-upload-more-list')
                            .append('<div class="layui-upload-img-div" id="upload_img_' + arr[2] + '"><img src="' + imgSrc + '" title="'
                                + arr[1] + '" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\'' + "${fileHttpPre}"
                                + arr[3] + '\');">查看</a><a href="javascript:void(0)" onclick="del(\''
                                + arr[2] + '\')";>删除</a></div><p>' + arr[1] + '</p><input type="hidden" value="'
                                + contractInfo + '" id="fileAtt_' + arr[2] + '" name="fileAtts" ></input></div> ');
                    }
                }
            },
            strFn(str) {
                str = str + ',';
                let arr = str.split(',');
                let arr1 = [];
                arr.map(el => {
                    if (el && el != 'null') {
                        arr1.push(el)
                    }
                })
                return arr1
            },
            arrFilter(arr, name) {
                let obj = {};
                if (arr.length > 0) {
                    arr.map(el => {
                        if (el.bidName === name) {
                            obj = el;
                        }
                    })
                    return obj
                } else {
                    return ''
                }

            },
            strFn(str) {
                str = str + ',';
                let arr = str.split(',');
                let arr1 = [];
                arr.map(el => {
                    if (el && el != 'null') {
                        arr1.push(el)
                    }
                })
                return arr1
            },
            queryProcessList() {
                let that = this;
                $.ajax({
                    type: 'post',
                    url: basePath + '/historyProcess/proNodeDetail',  //请求数据接口
                    data: {processId: that.processId},
                    success: function (result) {
                        that.procNodeList = result.entity.procNodeList;
                        that.tempNodeList = result.entity.tempNodeList;
                        that.info = result.entity.detailJson.projectInfo;
                        that.bidInfo = result.entity.detailJson.bidInfo;
                        let arr = [];
                        if (result.entity.detailJson.businessDetails) {//商务标
                            result.entity.detailJson.businessDetails.bidName = '商务标';
                            result.entity.detailJson.businessDetails.commerceCooperateSguids = that.strFn(result.entity.detailJson.businessDetails.commerceCooperateSguids)
                            that.memberArr.push(result.entity.detailJson.businessDetails)
                            if (result.entity.detailJson.businessDetails.commercePeopleSguid) {
                                arr.push(result.entity.detailJson.businessDetails.commercePeopleSguid)
                            }
                            if (result.entity.detailJson.businessDetails.commerceCooperateSguids && result.entity.detailJson.businessDetails.commerceCooperateSguids.length > 0) {
                                let businessDetailsArr = result.entity.detailJson.businessDetails.commerceCooperateSguids
                                businessDetailsArr.map(el => {
                                    arr.push(el)
                                })
                            }
                        }
                        if (result.entity.detailJson.creditDetail) {//资信标
                            result.entity.detailJson.creditDetail.bidName = '资信标';
                            result.entity.detailJson.creditDetail.commerceCooperateSguids = that.strFn(result.entity.detailJson.creditDetail.commerceCooperateSguids)
                            that.memberArr.push(result.entity.detailJson.creditDetail)
                            if (result.entity.detailJson.creditDetail.commercePeopleSguid) {
                                arr.push(result.entity.detailJson.creditDetail.commercePeopleSguid)
                            }
                            if (result.entity.detailJson.creditDetail.commerceCooperateSguids && result.entity.detailJson.creditDetail.commerceCooperateSguids.length > 0) {
                                let creditDetailArr = result.entity.detailJson.creditDetail.commerceCooperateSguids
                                creditDetailArr.map(el => {
                                    arr.push(el)
                                })
                            }
                        }
                        if (result.entity.detailJson.technicalDetail) {//技术标
                            result.entity.detailJson.technicalDetail.bidName = '技术标'
                            result.entity.detailJson.technicalDetail.commerceCooperateSguids = that.strFn(result.entity.detailJson.technicalDetail.commerceCooperateSguids)
                            that.memberArr.push(result.entity.detailJson.technicalDetail);
                            if (result.entity.detailJson.technicalDetail.commercePeopleSguid) {
                                arr.push(result.entity.detailJson.technicalDetail.commercePeopleSguid)
                            }
                            if (result.entity.detailJson.technicalDetail.commerceCooperateSguids && result.entity.detailJson.technicalDetail.commerceCooperateSguids.length > 0) {
                                // arr.concat(result.entity.detailJson.technicalDetail.commerceCooperateSguids)
                                let technicalDetailArr = result.entity.detailJson.technicalDetail.commerceCooperateSguids;
                                technicalDetailArr.map(el => {
                                    arr.push(el)
                                })
                            }
                        }
                        if (fileArr.length == 0) {
                            that.showFile(result.entity.detailJson.fileAtt);
                        }
                    }
                });
            },
        }
    })
</script>
</body>
</html>

